ARCH = $(shell uname -m)

top_builddir = ./../../../../../../

CXX = g++
CXXFLAGS = -fPIC -fstack-protector-all -Wl,-z,relro,-z,now
SHARED = -shared
TARGET = libeSDKLogAPI.so
LIBS = ../../../../../../output/kernel/platform/Huawei_Secure_C/comm/lib/libsecurec.a
INCLUDEDIR = -I ../../../../../../output/kernel/platform/Huawei_Secure_C/comm/include -I ../output/include -I ../ -I ../vos -I../log4cpp

.cpp.o:
	$(CXX) $(CXXFLAGS) $(INCLUDEDIR) $(LIBS) -c -DENV_LINUX -DLOG4CPP_HAVE_SSTREAM $< -o $@

SOURCES = $(wildcard *.cpp) $(wildcard ./../vos/*.cpp)
OBJS = $(patsubst %.cpp,%.o,$(SOURCES))
OBJS := $(sort $(OBJS))

$(TARGET): $(OBJS)
ifeq ($(ARCH), aarch64)
	$(CXX) $(CXXFLAGS) $(SHARED) -DDEBUG -DENV_LINUX $^ -L../C/aarch64 -llog4cpp $(LIBS) -o $(TARGET) -lpthread
else
	$(CXX) $(CXXFLAGS) $(SHARED) -DDEBUG -DENV_LINUX $^ -L../C/linux_64 -llog4cpp $(LIBS) -o $(TARGET) -lpthread
endif

.PHONY: clean
clean:
	-rm -f $(TARGET) $(OBJS)

